/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * formException.java
 *
 * Created on Mar 14, 2009, 7:18:35 PM
 */

package GUI.other;

import Interfaces.Loadable;
import functions.Dogy;

/**
 *
 * @author JArik
 */
public class LoadingForm extends javax.swing.JPanel {

    /** Creates new form formException */
    Loadable obj;
    public LoadingForm(String text) {
        initComponents();
        messageField.setText(text);
        
    }

    public LoadingForm(String text, Loadable obj) 
    {
        initComponents();
        messageField.setText(text);
        this.obj = obj;
    }
    public Loadable getLoadable()
    {
        return obj;
    }
    public void setProgress(int val)
    {
        progressBar.setValue(val);
    }

    public void progressFurther(int val)
    {
        progressBar.setValue(progressBar.getValue()+val);
    }

    public void setDescrLabel(String txt)
    {
        descrLabel.setText(txt);
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        messageField = new javax.swing.JLabel();
        cancelButton = new javax.swing.JButton();
        descrLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        messageField.setFont(new java.awt.Font("Tahoma", 1, 12));
        messageField.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        messageField.setText("Загрузка");

        cancelButton.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cancelButton.setText("Отменить");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        descrLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
        descrLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(descrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
                            .addComponent(messageField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
                            .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(98, 98, 98)
                        .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(messageField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(descrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(cancelButton))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        Dogy.stopLoading();
    }//GEN-LAST:event_cancelButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel descrLabel;
    private javax.swing.JLabel messageField;
    private javax.swing.JProgressBar progressBar;
    // End of variables declaration//GEN-END:variables

}
